package com.loop.unclelend.ui.adapter

import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.loop.unclelend.R
import com.loop.unclelend.utils.adapter.UncleRecyclerViewAdapter
import com.loop.unclelend.utils.adapter.UncleViewHolderHelper
import org.json.JSONObject

/**
 * UncleLend
 * @Author wwdeng
 * @CreateTime: 2024/9/9 16:14
 * @Annotation：主页tab
 */
class Adapter_MainTab(recyclerView: RecyclerView?) : UncleRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.uncle_item_tab) {

    override fun setItemChildListener(helper: UncleViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.layout_item) //点击Item
    }

    override fun fillData(helper: UncleViewHolderHelper, position: Int, model: JSONObject) {
        val imgTab = helper.getImageView(R.id.img_tab)
        val txtTab = helper.getTextView(R.id.txt_tab)
        txtTab.text = model.optString("tabTitle")

        val isSelect = model.optBoolean("isSelect", false)
        when(isSelect){
            true -> {
                txtTab.setTextColor(Color.parseColor("#FF7000FF"))
                imgTab.setImageResource(model.optInt("tabImageSelect"))
            }
            else -> {
                txtTab.setTextColor(Color.parseColor("#FF747378"))
                imgTab.setImageResource(model.optInt("tabImageNormal"))
            }
        }
    }
}